001 /* 002 * Copyright 2006 Stephen J. McConnell. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 013 * implied. 014 * 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package net.dpml.util; 020 021 import java.net.URI; 022 import java.net.URISyntaxException; 023 024 /** 025 * Interace implemented by a value (key, ref, and property) resolver. 026 * 027 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a> 028 * @version 1.0.1 029 */ 030 public interface Resolver 031 { 032 /** 033 * Utility function supporting resolution of uris containing 'resource' or 034 * 'alias' schemes. If the supplied uri scheme is 'resource' or 'alias' the 035 * reference is resolved to a artifact type, group and name from which a 036 * resource is resolved and the uri returned. If the scheme is resource 037 * the usi of the resource is returned. If the scheme is 'alias' a 038 * link alias is returned. If the scheme is not 'resource' or 'alias' 039 * the argument will be evaluated as a normal transit artifact uri 040 * specification. 041 * 042 * @param ref the uri argument 043 * @return the uri value 044 * @exception URISyntaxException if an error occurs during uri creation 045 */ 046 URI toURI( String ref ) throws URISyntaxException; 047 048 /** 049 * Return a property value. 050 * @param key the property key 051 * @return the property value 052 */ 053 String getProperty( String key ); 054 055 /** 056 * Return a property value. 057 * @param key the property key 058 * @param value the default value 059 * @return the property value 060 */ 061 String getProperty( String key, String value ); 062 063 /** 064 * Symbolic expansion of a supplied value. 065 * Replace any occurances of ${[key]} with the value of the property 066 * assigned to the [key] in system properties. 067 * @param value a string containing possibly multiple ${[value]} sequences 068 * @return the expanded string 069 */ 070 String resolve( String value ); 071 }